/*
 * kWatchDog.h
 *
 *  Created on: Mar 15, 2012
 *      Author: kylintse
 */

#ifndef KWATCHDOG_H_
#define KWATCHDOG_H_

#include "QtCore"

typedef struct _tkWatchDogItem
{
	QString name;
	quint32 time;
	quint32 counter;
}kWatchDogItem;

class kWatchDog : public QThread
{
	Q_OBJECT
public:
	kWatchDog(QObject* parent=0);
	virtual ~kWatchDog();

public:
	qint32 registerWatchDog(const QString& name,quint32 time);
	void unregisterWatchDog(qint32 id);
	void resetWatchDog(qint32 id);

protected:
	virtual void run();

protected slots:
	void watchDogTimer();

private:
	QMutex	m_lockWatchDog;
	QMap<qint32,kWatchDogItem*> m_watchDogs;

	QAtomicInt m_curId;
};

#endif /* KWATCHDOG_H_ */
